<?php
/**
 * 保险人员操作控制类
 * User: Administrator
 * Date: 2018/10/29 0029
 * Time: 21:34
 */

namespace app\index\controller;

use  think\Controller;
use  module\InsurerApi;
use  think\Validate;
use  think\Request;
use  model\UserInfoModel;
use  library\Validator;
use  module\UserApi;
use model\PolicyModel;
use think\Db;
class Insurer extends CommonController
{

    /**
     *  保险录入 展示第一步
     */
    public function step1()
    {
        $policy_num = input('get.policy_num');
        $info['policy_num'] = '';
        $info['report_num'] = '';
        $info['insurance_type'] = '';
        $info['insurance_name'] = '';
        if (!empty($policy_num)) {
            $info = Db::table('policy')->field('policy_num,report_num,insurance_type')->where('ui_id', $this->uid)->where('policy_num', $policy_num)->find();
            $typeInfo = Db::table('insurance_type')->where('it_id', $info['insurance_type'])->find();
            $info['insurance_name'] = $typeInfo['it_name'];
        }
        return $this->response->api($info);
        //return $this->fetch('insurer/step_1',['policy_num'=>$info['policy_num'],'report_num'=>$info['report_num'],'insurance_type'=>$info['insurance_type'],'insurance_name'=>$info['insurance_name']]);
    }

    /**
     *  保险录入 展示第二步
     */
    public function step2()
    {
        $policy_num = input('get.policy_num');
        $info = [];
        $info['goods_type_name'] = '';
        if (!empty($policy_num)) {
            $info = InsurerApi::getInfoByWherePolicyItem(['policy_num' => $policy_num], ['goods_type,goods_name,goods_num,good_price,good_pg_price']);
            $typeInfo = Db::table('goods_type')->where('gt_id', $info['goods_type'])->find();
            $info['goods_type_name'] = $typeInfo['gt_name'];
        }
        return $this->response->api(array_merge($info, ['policy_num' => $policy_num, 'p_id']));
//        return $this->fetch('insurer/step_2',['policy_num'=>$policy_num,'info'=>$info]);
    }

    /**
     *  保险录入 展示第三步
     */
    public function step3()
    {
        $policy_num = input('get.policy_num');
        $info = [];
        if (!empty($policy_num)) {
            $info = InsurerApi::getInfoByWherePolicyItem(['policy_num' => $policy_num], ['damage_at,damage_result,omit,city,classify,address_detail,other_report']);
        }
        $str = '';
        if (isset($info['omit']) && $info['omit']) {
            $str .= $info['omit'] . ' ';
        }
        if (isset($info['city']) && $info['city']) {
            $str .= $info['city'] . ' ';
        }
        if (isset($info['classify']) && $info['classify']) {
            $str .= $info['classify'];
        }
        return $this->response->api(array_merge($info, ['policy_num' => $policy_num, 'policy_num' => $policy_num, 'addr' => $str]));
        // return $this->fetch('insurer/step_3',['policy_num'=>$policy_num,'info'=>$info,'addr'=>$str]);
    }

    /**
     *  保险录入 展示第四步
     */
    public function step4()
    {
        $policy_num = input('get.policy_num');
        $info = [];
        if (!empty($policy_num)) {
            $info = InsurerApi::getInfoByWherePolicyItem(['policy_num' => $policy_num], ['present_at,goods_list,goods_desc,present_img,present_video']);
        }
        return $this->response->api(array_merge($info, ['policy_num' => $policy_num]));
//        return $this->fetch('insurer/step_4',['policy_num'=>$policy_num,'info'=>$info]);
    }

    /**
     *  保险录入 展示第五步
     */
    public function step5()
    {
        $policy_num = input('get.policy_num');
        $info = [];
        if (!empty($policy_num)) {
            $info = InsurerApi::getInfoByWherePolicyItem(['policy_num' => $policy_num], ['should_at,rem_company,linkman,connect_phone']);
        }
        return $this->response->api(array_merge($info, ['policy_num' => $policy_num]));
        // return $this->fetch('insurer/step_5',['policy_num'=>$policy_num,'info'=>$info]);
    }

    /**
     *  保险录入 展示第六步
     */
    public function step6()
    {
        $policy_num = input('get.policy_num');
        return $this->response->api(['policy_num' => $policy_num]);
        //return $this->fetch('insurer/step_6',['policy_num'=>$policy_num]);
    }

    /**
     *  保险录入 修改
     */
    public function addInsurer()
    {
        list($policy_num, $report_num, $insurance_type, $goods_type, $good_name, $goods_num, $good_price, $good_pg_price, $damage_at, $damage_result, $omit, $city, $classify, $address_detail, $other_report, $present_at, $goods_list, $goods_desc, $present_img, $present_video, $should_at, $rem_company, $linkman, $connect_phone, $author_report, $now_status) = Validator::make($this->request->request(), [
            'policy_num' => 'required|alpha_num',
            'report_num' => 'alpha_num',
            'insurance_type' => '',
            'goods_type' => '',
            'goods_name' => 'max:30',
            'goods_num' => '',
            'good_price' => 'numeric',
            'good_pg_price' => 'numeric',
            'damage_at' => '',
            'damage_result' => '',
            'omit' => '',
            'city' => '',
            'classify' => '',
            'address_detail' => '',
            'other_report' => '',
            'present_at' => '',
            'goods_list' => '',
            'goods_desc' => '',
            'present_img' => '',
            'present_video' => '',
            'should_at' => '',
            'rem_company' => 'max:30',
            'linkman' => 'alpha|max:20',
            'connect_phone' => 'cellphone',
            'author_report' => '',//授权书
            'now_status' => 'required'
        ]);
        $policy_data = [
            'ui_id' => $this->uid,
            'policy_num' => $policy_num,
            'now_status' => $now_status,
        ];
        $policy_item_data = [];
        //主表开始
        if ($report_num) {
            $policy_data['report_num'] = $report_num;
        }
        if ($insurance_type) {
            $policy_data['insurance_type'] = $insurance_type;
        }
//        if ($insurance_type) {
//            $policy_data['insurance_type'] = $insurance_type;
//        }
//        if ($insurance_type) {
//            $policy_data['insurance_type'] = $insurance_type;
//        }
        //副表开始
        if ($goods_type) {
            $policy_item_data['goods_type'] = $goods_type;
        }
        if ($good_name) {
            $policy_item_data['goods_name'] = $good_name;
        }
        if ($goods_num) {
            $policy_item_data['goods_num'] = $goods_num;
        }
        if ($good_price) {
            $policy_item_data['good_price'] = $good_price;
        }
        if ($good_pg_price) {
            $policy_item_data['good_pg_price'] = $good_pg_price;
        }
        if ($damage_at) {
            $policy_item_data['damage_at'] = $damage_at;
        }
        if ($damage_result) {
            $policy_item_data['damage_result'] = $damage_result;
        }

        $policy_item_data['omit'] = $omit;

        if ($city) {
            $policy_item_data['city'] = $city;
        }
        if ($classify) {
            $policy_item_data['classify'] = $classify;
        }
        if ($address_detail) {
            $policy_item_data['address_detail'] = $address_detail;
        }
        if ($other_report) {
            $policy_item_data['other_report'] = $other_report;
        }
        if ($present_at) {
            $policy_item_data['present_at'] = $present_at;
        }
        if ($goods_list) {
            $policy_item_data['goods_list'] = $goods_list;
        }
        if ($goods_desc) {
            $policy_item_data['goods_desc'] = $goods_desc;
        }
        if ($present_img) {
            $policy_item_data['present_img'] = $present_img;
        }
        if ($present_video) {
            $policy_item_data['present_video'] = $present_video;
        }
        if ($should_at) {
            $policy_item_data['should_at'] = $should_at;
        }
        if ($rem_company) {
            $policy_item_data['rem_company'] = $rem_company;
        }
        if ($linkman) {
            $policy_item_data['linkman'] = $linkman;
        }
        if ($connect_phone) {
            $policy_item_data['connect_phone'] = $connect_phone;
        }
        if ($author_report) {
            $policy_item_data['author_report'] = $author_report;
        }
        if ($author_report) {
            $policy_item_data['author_report'] = $author_report;
        }
        $re = InsurerApi::insertPolicy($this->uid, $policy_num, $policy_data, $policy_item_data);
        if ($re) {
            return $this->response->api(['policy_num' => $policy_num], self::SUCCESS_CODE, '保存成功');
        } else {
            return $this->response->api([], self::ERROR_CODE, '保存失败');
        }
    }


    /**
     *  提交审核
     */
    public function confirmSubmit()
    {

        list($policy_num, $author_report) = Validator::make($this->request->request(), [
            'policy_num' => 'required|alpha_num',
            'author_report' => '', //授权书
        ]);
        $now_status = 6;
        // 确认提交未待审核状态
        $re = InsurerApi::confirmSubmit($this->uid, $policy_num, $now_status, $author_report);
        if ($re !== false) {
            return $this->response->api([], self::SUCCESS_CODE, '提交成功');
        } else {
            return $this->response->api([], self::ERROR_CODE, '提交成功');
        }

    }

    /**
     *  历史资料列表
     */
    public function getList()
    {
        list($policy_num, $type) = Validator::make($this->request->request(), [
            'policy_num' => '',
            'type' => '', //状态
        ]);
        $list = InsurerApi::getList($this->uid, $policy_num, $type);
        return $this->response->api($list);
    }

    /**
     *  历史资料详情
     */
    public function insurerInfo()
    {

        $input = input('get.');
        $validate = new Validate([
            'p_id' => 'require',
        ]);
        if (!$validate->check($input)) {
            return $this->response->api([], self::ERROR_CODE, '请上传资料id');
        }
        $statusArr = [0 => '驳回修改', 1 => '未递交审核', 2 => '代录人未递交', 3 => '代录资料未确认', 4 => '待审核', 5 => '被保险人未确认', 6 => '被保险人未委托', 7 => '全部资料已完成', 8 => '拍卖已完成'];
        $info = InsurerApi::getInfo($input['p_id'], $this->uid);
        $data = [];
        $recordor_info = [];
        $userModel = New UserInfoModel();
        $data['bohui_info'] = [];
        if ($info) {
            if ($info['recordor_id'] > 0) {
                //判断是否代录人 录入   有查找相关信息
                $recordor_info = $userModel->get($info['recordor_id']);
            }
            if ($info['remer_id'] > 0) {
                $remer_info = $userModel->get($info['remer_id']);
            }
            //资料头部信息
            $data['status'] = $info['policy_status'];
            $data['info']['stataus_str'] = isset($statusArr[$info['policy_status']]) ? $statusArr[$info['policy_status']] : '';
            //代录人信息
            $data['info']['recordor_name'] = !empty($recordor_info['username']) ? $recordor_info['username'] : '';
            $data['info']['recordor_phone'] = !empty($recordor_info['mobile']) ? $recordor_info['mobile'] : '';
            if (!empty($recordor_info['recoder_type'])) {
                $recordorInfo = Db::table('recorder_type')->where('id', $recordor_info['recoder_type'])->find();
                $data['info']['recordor_type'] = $recordorInfo['name'];
            } else {
                $data['info']['recordor_type'] = '';
            }

            //代入人截止时间  只有代录人未提交字段 才显示此字段
            $data['info']['recordor_commit'] = $info['policy_status'] == 2 ? date('Y-m-d H:i', strtotime($info['end_at'])) : '';
            //物权人信息
            $data['info']['remer_confirm_at'] = '';
            $data['info']['remer_entrust_at'] = '';
            $data['info']['remer_chu_at'] = '';
            $data['info']['remer_end_at'] = '';
            $data['info']['baogao'] = '';
            //待录人未提交或者未提交修改不显示此字段
            $data['info']['creat'] = !in_array($info['policy_status'], [1, 2]) ? date('Y-m-d H:i', strtotime($info['created_at'])) : '';


            //获取驳回信息  只有驳回状态 才有
            if ($info['policy_status'] == PolicyModel::POLICY_REVISE_STATUS) {
                $data['bohui_info'] = InsurerApi::getRetuenList($info['p_id']);
            }
            unset($info['ui_id']);
            unset($info['recordor_id']);
            unset($info['remer_id']);
            unset($info['end_at']);
            unset($info['created_at']);
            unset($info['updated_at']);
            unset($info['delete_ts']);
            unset($info['admin_id']);
            unset($info['policy_status']);
            unset($info['recoder_status']);
            unset($info['now_status']);
            unset($info['pi_id']);
            $info['goods_type_name'] = $info['insurance_type_name'] = '';
            $info['present_img'] = $info['present_img'] ? json_decode($info['present_img']) : '';
            $info['goods_list'] = $info['goods_list'] ? json_decode($info['goods_list']) : '';
            $info['other_report'] = $info['other_report'] ? json_decode($info['other_report']) : '';
            if ($info['other_report']) {
                foreach ($info['other_report'] as $k => $v) {
                    if (!$v) continue;
                    preg_match('/\/([^\/]+\.[a-z]+)[^\/]*$/', $v, $match);
                    array_push($info['other_report'], ['url' => $v, 'name' => $match[1]]);
                    unset($info['other_report'][$k]);
                }
            }
            if ($info['goods_list']) {
                foreach ($info['goods_list'] as $k => $v) {
                    if (!$v) continue;
                    preg_match('/\/([^\/]+\.[a-z]+)[^\/]*$/', $v, $match);
                    array_push($info['goods_list'], ['url' => $v, 'name' => $match[1]]);
                    unset($info['goods_list'][$k]);
                }
            }
            if ($info['goods_type']) {
                $goodTypeInfo = Db::table('goods_type')->where('gt_id', $info['goods_type'])->find();
                $info['goods_type_name'] = $goodTypeInfo['gt_name'];
            }
            if ($info['insurance_type']) {
                $insuranceTypeInfo = Db::table('insurance_type')->where('it_id', 'in', $info['insurance_type'])->select();

                foreach ($insuranceTypeInfo as $v) {
                    $info['insurance_type_name'] .= $v['it_name'] . ',';
                }
                $info['insurance_type_name'] = rtrim($info['insurance_type_name'], ',');
            }
            // $data['policy_info']=['policy_num'=>$info['policy_num'],'report_num'=>$info['report_num'],'insurance_type'=>$info['insurance_type']];
            // $data['goods_info']=['goods_type'=>$info['goods_type'],'goods_name'=>$info['goods_name'],'goods_num'=>$info['goods_num'],'good_price'=>$info['good_price'],'good_pg_price'=>$info['good_pg_price']];
            // $data['under_info']=['damage_at'=>$info['damage_at'],'damage_result'=>$info['damage_result'],'omit'=>$info['omit'],'city'=>$info['city'],'classify'=>$info['classify'],'address_detail'=>$info['address_detail'],'other_report'=>$info['other_report']];
            //$data['situation_info']=['present_at'=>$info['present_at'],'goods_list'=>$info['goods_list'],'goods_desc'=>$info['goods_desc'],'present_img'=>$info['present_img'],'present_video'=>$info['present_video']];
            // $data['interest_info'] =['should_at'=>$info['should_at'],'rem_company'=>$info['rem_company'],'linkman'=>$info['linkman'],'connect_phone'=>$info['connect_phone']];
            // $data['author_info']=['author_report'=>$info['author_report']];
            $data['goods_info'] = $info;
        }

        return $this->response->api($data);


    }

    /**
     *  他人代录
     */

    public function otherInsurer()
    {

        list($apolicy_num, $report_num, $insurance_type, $end_at, $recordor_id) = Validator::make($this->request->request(), [
            'policy_num' => 'required|alpha_num',
            'report_num' => 'required|alpha_num',
            'insurance_type' => 'required',
            'end_at' => 'required|date',
            'recordor_id' => 'required'
        ]);
        $policy_data = [
            'ui_id' => $this->uid,
            'policy_num' => $apolicy_num,
            'report_num' => $report_num,
            'insurance_type' => $insurance_type,
            'recordor_id' => $recordor_id,
            'policy_status' => 2,
            'recoder_status' => 0,//此时保险人员为代录状态
            'end_at' => $end_at,
            'created_at' => date('Y-m-d H:i:s'),
        ];
        $info = Db::table('policy')->where('policy_num', $apolicy_num)->find();
        if ($info) {
            return $this->response->api([], self::ERROR_CODE, '保单号重复');
        }
        $re = InsurerApi::insertOtherPolicy($policy_data);
        if ($re) {
            return $this->response->api([]);
        } else {
            return $this->response->api([], self::ERROR_CODE, '添加失败');
        }
    }

    /**
     *  代录人列表
     */
    public function otherList()
    {

        $list = UserApi::getOtherList($this->uid);
        return $this->response->api($list);
    }

    /**
     *  绑定代录人
     */
    public function bindOther()
    {
        list($mobile, $realName, $recoder_type, $card_num, $rem_comname, $rem_link_name, $rem_link_phone) = Validator::make($this->request->request(), [
            'mobile' => 'required|cellphone',
            'realName' => 'required',
            'recoder_type' => 'required|numeric',
            'card_num' => 'required',
            'rem_comname' => 'required',
            'rem_link_name' => 'required',
            'rem_link_phone' => 'required|cellphone',
        ]);
        $e = UserApi::bindOther($this->uid, $mobile, $realName, $recoder_type, $card_num, $rem_comname, $rem_link_name, $rem_link_phone);
        if ($e) {
            return $this->response->api([], self::SUCCESS_CODE, '添加成功');
        } else {
            return $this->response->api([], self::ERROR_CODE, '添加失败');
        }
    }

    /**
     *  解除绑定
     */
    public function unbindOther()
    {
        list($recordor_id) = Validator::make($this->request->request(), [
            'recordor_id' => 'required'
        ]);
        $e = UserApi::unbindOther($this->uid, $recordor_id);
        if ($e) {
            return $this->response->api([], self::SUCCESS_CODE, '删除成功');
        } else {
            return $this->response->api([], self::ERROR_CODE, '删除失败');
        }
    }

    /**
     *  驳回  驳回代录人  业务员也可以用此方法
     */
    public function reject()
    {
        list($p_id, $policy_return, $goods_return, $under_return, $situation_return, $info_return, $certificate_return) = Validator::make($this->request->request()->post(), [
            'p_id' => 'required',
            'policy_return' => '',//保险单种驳回信息
            'goods_return' => '',//货品信息驳回信息
            'under_return' => '',//货品受损驳回信息
            'situation_return' => '',//货品现状驳回信息
            'info_return' => '',//物权信息驳回信息
            'certificate_return' => ''//授权书驳回信息
        ]);
        $insert = [];
        if ($policy_return) {
            $insert['policy_return'] = $policy_return;
        }
        if ($goods_return) {
            $insert['goods_return'] = $goods_return;
        }
        if ($under_return) {
            $insert['under_return'] = $under_return;
        }
        if ($situation_return) {
            $insert['situation_return'] = $situation_return;
        }
        if ($info_return) {
            $insert['info_return'] = $info_return;
        }
        if ($certificate_return) {
            $insert['certificate_return'] = $certificate_return;
        }

        $re = InsurerApi::reject($this->uid, $p_id, $insert);

        return $this->response->api([], self::SUCCESS_CODE, '驳回成功');

    }


    /**
     *  保险人修改 修改 修改
     */
    public function update()
    {

        list($policy_num, $goods_type, $good_name, $goods_num, $good_price, $good_pg_price, $damage_at, $damage_result, $omit, $city, $classify, $address_detail, $other_report, $present_at, $goods_list, $goods_desc, $present_img, $present_video, $should_at, $rem_company, $linkman, $connect_phone) = Validator::make($this->request->request(), [
            'policy_num' => 'required|alpha_num',
            'goods_type' => '',
            'goods_name' => '',
            'goods_num' => '',
            'good_price' => '',
            'good_pg_price' => '',
            'damage_at' => '',
            'damage_result' => '',
            'omit' => '',
            'city' => '',
            'classify' => '',
            'address_detail' => '',
            'other_report' => '',
            'present_at' => '',
            'goods_list' => '',
            'goods_desc' => '',
            'present_img' => '',
            'present_video' => '',
            'should_at' => '',
            'rem_company' => '',
            'linkman' => '',
            'connect_phone' => 'cellphone',
        ]);
        $policy_item_data['policy_num'] = $policy_num;
        //副表开始
        if ($goods_type) {
            $policy_item_data['goods_type'] = $goods_type;
        }
        if ($good_name) {
            $policy_item_data['goods_name'] = $good_name;
        }
        if ($goods_num) {
            $policy_item_data['goods_num'] = $goods_num;
        }
        if ($good_price) {
            $policy_item_data['good_price'] = $good_price;
        }
        if ($good_pg_price) {
            $policy_item_data['good_pg_price'] = $good_pg_price;
        }
        if ($damage_at) {
            $policy_item_data['damage_at'] = $damage_at;
        }
        if ($damage_result) {
            $policy_item_data['damage_result'] = $damage_result;
        }
        $policy_item_data['omit'] = $omit;
        if ($city) {
            $policy_item_data['city'] = $city;
        }
        if ($classify) {
            $policy_item_data['classify'] = $classify;
        }
        if ($address_detail) {
            $policy_item_data['address_detail'] = $address_detail;
        }
        if ($other_report) {
            $policy_item_data['other_report'] = $other_report;
        }
        if ($present_at) {
            $policy_item_data['present_at'] = $present_at;
        }
        if ($goods_list) {
            $policy_item_data['goods_list'] = $goods_list;
        }
        if ($goods_desc) {
            $policy_item_data['goods_desc'] = $goods_desc;
        }
        if ($present_img) {
            $policy_item_data['present_img'] = $present_img;
        }
        if ($present_video) {
            $policy_item_data['present_video'] = $present_video;
        }
        if ($should_at) {
            $policy_item_data['should_at'] = $should_at;
        }
        if ($rem_company) {
            $policy_item_data['rem_company'] = $rem_company;
        }
        if ($linkman) {
            $policy_item_data['linkman'] = $linkman;
        }
        if ($connect_phone) {
            $policy_item_data['connect_phone'] = $connect_phone;
        }

        $re = InsurerApi::updateByPolicy($this->uid, $policy_num, $policy_item_data);
        if ($re) {
            return $this->response->api(['policy_num' => $policy_num], self::SUCCESS_CODE, '保存成功');
        } else {
            return $this->response->api([], self::ERROR_CODE, '保存失败');
        }
    }


    /**
     *  保险人删除
     */
    public function delete()
    {
        list($apolicy_num) = Validator::make($this->request->request(), [
            'policy_num' => 'required|alpha_num',
        ]);
        $r = Db::table('policy')->where('policy_num', $apolicy_num)->delete();
        $re = Db::table('policy_item')->where('policy_num', $apolicy_num)->delete();
        if ($r && $re) {
            return $this->response->api([]);
        } else {
            return $this->response->api([], self::ERROR_CODE, '删除失败');
        }

    }

    public function authList()
    {

        $list = Db::table('policy')->field('p_id,policy_num,remer_id,proxy_num')->where('ui_id', $this->uid)->where('delete_ts', 0)->select();
        $list = $list ? $list : [];
        if (!$list) return $this->response->api($list);

        foreach ($list as $k => $v) {
            if ($v['remer_id'] > 0) {
                $info = Db::table('user_info')->where('ui_id', $v['remer_id'])->find();
                $list[$k]['name'] = $info['username'];
            } else {
                $list[$k]['name'] = '';
            }
        }
        return $this->response->api($list);

    }

    public function book()
    {

        return $this->fetch('insurer/book');
    }


    /**
     *  修改完提交
     */
    public function confirmSubmitUpdate()
    {

        list($policy_num, $goods_type, $good_name, $goods_num, $good_price, $good_pg_price, $damage_at, $damage_result, $omit, $city, $classify, $address_detail, $other_report, $present_at, $goods_list, $goods_desc, $present_img, $present_video, $should_at, $rem_company, $linkman, $connect_phone, $author_report) = Validator::make($this->request->request(), [
            'policy_num' => 'required|alpha_num',
            'goods_type' => '',
            'goods_name' => 'max:30',
            'goods_num' => '',
            'good_price' => 'numeric',
            'good_pg_price' => 'numeric',
            'damage_at' => '',
            'damage_result' => '',
            'omit' => '',
            'city' => '',
            'classify' => '',
            'address_detail' => '',
            'other_report' => '',
            'present_at' => '',
            'goods_list' => '',
            'goods_desc' => '',
            'present_img' => '',
            'present_video' => '',
            'should_at' => '',
            'rem_company' => 'max:30',
            'linkman' => 'alpha|max:20',
            'connect_phone' => 'cellphone',
            'author_report' => '',//授权书
        ]);
        $now_status = 6;
        $policy_item_data=[];
        //副表开始
        if ($goods_type) {
            $policy_item_data['goods_type'] = $goods_type;
        }
        if ($good_name) {
            $policy_item_data['goods_name'] = $good_name;
        }
        if ($goods_num) {
            $policy_item_data['goods_num'] = $goods_num;
        }
        if ($good_price) {
            $policy_item_data['good_price'] = $good_price;
        }
        if ($good_pg_price) {
            $policy_item_data['good_pg_price'] = $good_pg_price;
        }
        if ($damage_at) {
            $policy_item_data['damage_at'] = $damage_at;
        }
        if ($damage_result) {
            $policy_item_data['damage_result'] = $damage_result;
        }
        $policy_item_data['omit'] = $omit;
        if ($city) {
            $policy_item_data['city'] = $city;
        }
        if ($classify) {
            $policy_item_data['classify'] = $classify;
        }
        if ($address_detail) {
            $policy_item_data['address_detail'] = $address_detail;
        }
        if ($other_report) {
            $policy_item_data['other_report'] = $other_report;
        }
        if ($present_at) {
            $policy_item_data['present_at'] = $present_at;
        }
        if ($goods_list) {
            $policy_item_data['goods_list'] = $goods_list;
        }
        if ($goods_desc) {
            $policy_item_data['goods_desc'] = $goods_desc;
        }
        if ($present_img) {
            $policy_item_data['present_img'] = $present_img;
        }
        if ($present_video) {
            $policy_item_data['present_video'] = $present_video;
        }
        if ($should_at) {
            $policy_item_data['should_at'] = $should_at;
        }
        if ($rem_company) {
            $policy_item_data['rem_company'] = $rem_company;
        }
        if ($linkman) {
            $policy_item_data['linkman'] = $linkman;
        }
        if ($connect_phone) {
            $policy_item_data['connect_phone'] = $connect_phone;
        }
        // 确认提交未待审核状态
        $re = InsurerApi::confirmSubmit($this->uid, $policy_num, $now_status, $policy_item_data);
        if ($re !== false) {
            return $this->response->api([], self::SUCCESS_CODE, '修改提交成功');
        } else {
            return $this->response->api([], self::ERROR_CODE, '修改提交失败');
        }


    }
}